package com.xre.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.xbz.core.service.mvc.servlet.FlowServlet;

@Configuration
public class XREngineConfig {
	
	@Value("${xr.engine.context-path:}")
	private String contextPath;
	
	@Value("${xr.engine.service-path:/xr}")
	private String servicePath;
	
	@Value("${xr.engine.config-path:$/config}")
	private String configPath;
	
	@Bean
	public ServletRegistrationBean<FlowServlet> servletRegistrationBean() {
		// 初始化
		ServletRegistrationBean<FlowServlet> servletRegistrationBean = new ServletRegistrationBean<FlowServlet>(new FlowServlet(), servicePath + "/*");
		// 应用路径
		servletRegistrationBean.addInitParameter("contextPath", contextPath);
		// 服务路径
		servletRegistrationBean.addInitParameter("servicePath", servicePath);
		// 配置路径
		servletRegistrationBean.addInitParameter("configPath", configPath);
		servletRegistrationBean.setLoadOnStartup(1);
		return servletRegistrationBean;
	}
}